package com.shms.service.impl;
import java.util.List;

import com.shms.bean.GroupOfClass;
import com.shms.dao.ShClassDao;
import com.shms.entity.ShClass;
import com.shms.entity.ShStudent;
import com.shms.service.ShClassSevice;

public class ShClassServiceImpl implements  ShClassSevice {

	private ShClassDao shClassDao;
	public void setShClassDao(ShClassDao shClassDao) {
		this.shClassDao = shClassDao;
	}
	@Override
	public GroupOfClass queryClass(GroupOfClass groupOfClass) {
		if (groupOfClass.getType().equals("forward")) {
			int currentPage = groupOfClass.getCurrentPage() - 2;
			groupOfClass.setCurrentPage(currentPage);
		}
		return shClassDao.queryClass(groupOfClass);
	}
	@Override
	public boolean batchDelete(Integer[] nos) {
		return this.shClassDao.batchDelete(nos);
	}
	@Override
	public boolean saveClasses(ShClass shClass) {
		boolean rtn = true;
		if (shClass.getCid() == 0) {
			rtn = shClassDao.saveClasses(shClass);
		} else {
			rtn = shClassDao.updateClasses(shClass);
		}
		return rtn;
	}
	
	public List<ShClass> queryAllCname(){
		return shClassDao.queryAllCname();
	}

	public ShClass queryById(ShClass shClass) {
		return shClassDao.queryById(shClass);
	}
	@Override
	public List<ShStudent> queryStudentsById(ShClass shClass) {
		return shClassDao.queryStudentsById(shClass);
	}
}
